//package com.springboot.util.word;
//
//import lombok.extern.slf4j.Slf4j;
//import org.jodconverter.DocumentConverter;
//import org.jodconverter.document.DefaultDocumentFormatRegistry;
//import org.jodconverter.document.DocumentFormat;
//import org.jodconverter.job.ConversionJobWithRequiredSourceFormatUnspecified;
//import org.jodconverter.job.ConversionJobWithSourceSpecified;
//import org.jodconverter.office.OfficeException;
//import org.springframework.stereotype.Component;
//
//import jakarta.annotation.Resource;
//import java.io.ByteArrayInputStream;
//import java.io.ByteArrayOutputStream;
//
///**
// * @author zyj
// * @description
// * @date 2019/7/3 9:50
// **/
//@Slf4j
//@Component
//public class WordCoverPdfUtil {
//
//    @Resource
//    private DocumentConverter documentConverter;
//
//    public ByteArrayOutputStream wordCoverPdf(ByteArrayOutputStream tmp) throws Exception{
//        try {
//            ByteArrayOutputStream pdfOut = new ByteArrayOutputStream();
//            ByteArrayInputStream swapStream = new ByteArrayInputStream(tmp.toByteArray());
//            ConversionJobWithRequiredSourceFormatUnspecified ss = documentConverter.convert(swapStream, true);
//            DocumentFormat formatReg = DefaultDocumentFormatRegistry.getFormatByExtension("docx");
//            ConversionJobWithSourceSpecified conversionJobWithSourceSpecified = ss.as(formatReg);
//            DocumentFormat formatReg1 = DefaultDocumentFormatRegistry.getFormatByExtension("pdf");
//            conversionJobWithSourceSpecified.to(pdfOut,true).as(formatReg1).execute();
//            return pdfOut;
//        } catch (OfficeException e) {
//            log.error("word转换pdf异常",e);
//            throw new RuntimeException("word转换pdf异常");
//        }
//    }
//
//    public ByteArrayOutputStream wordCoverPdf(byte[] tmp) throws Exception{
//        try {
//            ByteArrayOutputStream pdfOut = new ByteArrayOutputStream();
//            ByteArrayInputStream swapStream = new ByteArrayInputStream(tmp);
//            ConversionJobWithRequiredSourceFormatUnspecified ss = documentConverter.convert(swapStream, true);
//            DocumentFormat formatReg = DefaultDocumentFormatRegistry.getFormatByExtension("docx");
//            ConversionJobWithSourceSpecified conversionJobWithSourceSpecified = ss.as(formatReg);
//            DocumentFormat formatReg1 = DefaultDocumentFormatRegistry.getFormatByExtension("pdf");
//            conversionJobWithSourceSpecified.to(pdfOut,true).as(formatReg1).execute();
//            return pdfOut;
//        } catch (OfficeException e) {
//            log.error("word转换pdf异常",e);
//            throw new RuntimeException("word转换pdf异常");
//        }
//    }
//
//}
